package exam.wangyi8_21;

public class test2 {

    public static char findKthBit (int n, int k) {
        // write code here
        String[] s = new String[1000];
        s[1] = "a";
        for (int i = 2; i <= n; i++) {
            char l = (char) (i+'a'-1);
            s[i] = s[i-1]+l+reverse(invert(s[i-1]));
        }
        return s[n].charAt(k-1);
    }

    public static String reverse(String s){
        StringBuilder res= new StringBuilder();
        for (int i = s.length()-1; i >=0 ; i--) {
            res.append(s.charAt(i));
        }
        return res.toString();
    }
    public static String invert(String s){
        StringBuilder res= new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            char a =(char)('a' + 'z' - c);
            res.append(a);
        }
        return res.toString();
    }

    public static void main(String[] args) {
        System.out.println(findKthBit(2,3));
    }


}
